﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using InsuranceTests.classes;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace InsuranceTests
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestClass]
    public class UnitTest1
    {
        static private string СonneсtionString = @"Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=Test;
Integrated Security=True;Pooling=False";
        private Client x = new Client(1,123,32, Convert.ToDateTime("2010-11-12"),321,"ivan","Popov",01,"ip@mail.ru");
        private Flat y = new Flat(1,1,"Kom7",Convert.ToBoolean(0),4,0,2003,1600000);
        private Contract z = new Contract(1,3,1, Convert.ToBoolean(1), Convert.ToBoolean(1), Convert.ToBoolean(1), Convert.ToBoolean(1), Convert.ToBoolean(0), Convert.ToDateTime("2010-11-12"),0);
        private User q = new User(1,"2", 1, "Ivan", "Rukov",3123,"ir@mail.ru");
        private User w = new User(3, "2", 2, "Ivan", "Rukov", 3123, "ir@mail.ru");
        private Client e = new Client(3,333,1704, Convert.ToDateTime("2010-11-12"),535006,"ivan","Kotov",02,"ik@mail.ru");
        public UnitTest1()
        {
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestConnection()
        {
            Assert.AreEqual(1, dao.Connection(СonneсtionString));
        }
        [TestMethod]
        public void TestAddClient()
        {
            Assert.AreEqual(1, dao.AddClient(x));
        }
        [TestMethod]
        public void TestAddFlat()
        {
            Assert.AreEqual(1, dao.AddFlat(y));
        }
        [TestMethod]
        public void TestAddUser()
        {
            Assert.AreEqual(1, dao.AddUser(q));
        }
        [TestMethod]
        public void TestAddContract()
        {
            Assert.AreEqual(1, dao.AddContract(z));
        }
        [TestMethod]
        public void TestSearch()
        {
            Assert.AreEqual(1, dao.WatchContracts());
        }
        [TestMethod]
        public void TestAutorization()
        {
            Assert.AreEqual(1, dao.Autorization("1"));
        }
        [TestMethod]
        public void TestSearchUsers()
        {
            Assert.AreEqual(1, dao.WatchUsers());
        }
        [TestMethod]
        public void TestDelUsers()
        {
            Assert.AreEqual(1, dao.DeleteUser(w));
        }
        [TestMethod]
        public void TestUpdateUser()
        {
            Assert.AreEqual(1, dao.UpdateUser(q, w));
        }
        [TestMethod]
        public void TestSearchContract()
        {
            Assert.AreEqual(1, dao.SearchContract(1));
        }
        [TestMethod]
        public void TestSearchFlat()
        {
            Assert.AreEqual(1, dao.WatchFlat(1));
        }
        [TestMethod]
        public void TestUpdateFlat()
        {
            Assert.AreEqual(1, dao.UpdateClient(x,e));
        }
    }
}
